using System;
using System.Collections.Generic;
using System.Text;
using FlatRedBall;
using FlatRedBall.Input;
using FlatRedBall.Instructions;
using FlatRedBall.Graphics;
using FlatRedBall.AI.Pathfinding;
using FlatRedBall.Graphics.Animation;
using FlatRedBall.Graphics.Particle;

using FlatRedBall.Graphics.Model;
using FlatRedBall.Math.Geometry;
using FlatRedBall.Math.Splines;

using Cursor = FlatRedBall.Gui.Cursor;
using GuiManager = FlatRedBall.Gui.GuiManager;
using Microsoft.Xna.Framework.Input;

#if FRB_XNA || SILVERLIGHT
using Keys = Microsoft.Xna.Framework.Input.Keys;
using Vector3 = Microsoft.Xna.Framework.Vector3;
using Texture2D = Microsoft.Xna.Framework.Graphics.Texture2D;
using Gnome.Engine;
#endif

namespace Gnome.Screens
{
	public partial class PauseScreen
	{
        int selected;

		public void CustomInitialize()
		{
            
            selected = 0;
            PauseBackground.ScaleX = LevelBase.SCREEN_WIDTH / 2;
            PauseBackground.ScaleY = LevelBase.SCREEN_HEIGHT / 2;
            PauseBackground.Z = 1;

            Cursor.X = -10.0f;
            Cursor.Y = 5.5f;
            Cursor.Z = 1;
		}

		public void CustomActivity(bool firstTimeCalled)
		{
            if (CustomInputManager.isMenuCancel())
            {
                InstructionManager.UnpauseEngine();
                IsActivityFinished = true;
                ScreenManager.CurrentScreen.ShouldRemoveLayer = true;
            }
            if (CustomInputManager.isMenuDown())
            {
                //Move down list but up from play -> about -> etc
                selected++;
                if (selected > 2)
                    selected = 0;
                drawCursor();
            }
            else if (CustomInputManager.isMenuUp())
            {
                selected--;
                if (selected < 0)
                    selected = 2;
                drawCursor();
            }
            if (CustomInputManager.isMenuSelect())
            {
                
                
                switch (selected)
                {
                    case 0:
                        InstructionManager.UnpauseEngine();
                        IsActivityFinished = true;
                        ScreenManager.CurrentScreen.ShouldRemoveLayer = true;
                        break;
                    case 1:
                        IsActivityFinished = true;
                        InstructionManager.UnpauseEngine();
                        ScreenManager.CurrentScreen.ShouldRemoveLayer = true;
                        //ScreenManager.CurrentScreen.Destroy();
                        LevelBase.MoveToMainMenu = true;
                        break;
                    case 2:
                        Environment.Exit(0);
                        break;
                    default:
                        Console.WriteLine("ERROROROROROR");
                        break;
                }
            }
		}
        private void drawCursor()
        {
            Cursor.Y = 5.5F - selected * 5.5F;
        }
		public void CustomDestroy()
		{
            SpriteManager.RemoveSprite(Cursor);
            SpriteManager.RemoveSprite(PauseBackground);
		}

        private static void CustomLoadStaticContent(string contentManagerName)
        {


        }

	}
}
